package com.it.LoginSystem.controller;

import com.it.LoginSystem.Pojo.Emp;
import com.it.LoginSystem.Pojo.Result;
import com.it.LoginSystem.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping ("/api/login")
    //@RequestBody封装为json格式
    public Result login(@RequestBody Emp emp){
        log.info("用户登陆：{}",emp);
        Emp e = empService.login(emp);

        return e != null?Result.success(e):Result.error("用户名或密码错误,请检查输入并重试。");
    }

}
